草庐IT

Swift、Parse 和 Xcode 6 beta6

全部标签

c# - 比 decimal.Parse 更快的替代方法

我注意到decimal.Parse(number,NumberStyles.AllowDecimalPoint,CultureInfo.InvariantCulture)比基于JeffreySax来自FasteralternativetoConvert.ToDouble的代码的自定义十进制解析方法慢大约100%publicstaticdecimalParseDecimal(stringinput){boolnegative=false;longn=0;intlen=input.Length;intdecimalPosition=len;if(len!=0){intstart=0;if(

c# - 使用 Windows 范围内的 Beta UTF-8 支持功能时在 Winforms 中调整 RTF 的错误

我想我在Windows或.NET中发现了一个错误,正在寻找解决方法。要重现该问题,请首先启用Windows功能“Beta:使用UnicodeUTF-8以获得全局语言支持”。您可能需要重启机器。现在在Winforms/C#中简单的创建两个RichTextBox组件,然后添加事件:privatevoidrichTextBox1_TextChanged(objectsender,EventArgse){strings=richTextBox1.Rtf;richTextBox2.Rtf=s;}最后,运行该程序并在第一个RichTextBox中简单地键入一些内容,当它尝试写入richTextBo

c# - float.Parse 在小数点和逗号上失败

当我尝试这条线时:floatf=float.Parse(val,System.Globalization.NumberStyles.AllowDecimalPoint|System.Globalization.NumberStyles.AllowThousands);其中val是设置为“5.267”且不带引号的字符串,我收到此错误:格式异常:未知字符:。System.Double.Parse(System.Strings、NumberStyles样式、IFormatProvider提供程序)System.Single.Parse(System.Strings,NumberStyles样

c# - 我必须如何更改此 XML 字符串以便 XDocument.Parse 读取它?

在下面的代码中,我将一个对象序列化为一个XML字符串。但是当我尝试使用XDocument.Parse将此XML字符串读入XDocument时,它给了我这个错误:Invaliddataatrootlevel.XML是:1JimJones23434更新:这是十六进制:![alttext][1]Mod编辑-禁用超链接:指向恶意软件的链接我必须对该XML做什么才能使其无错误地读入XDocument?usingSystem;usingSystem.Collections.Generic;usingSystem.Xml.Serialization;usingSystem.IO;usingSyste

c# - long.Parse() C#

我如何在C#中将字符串(例如“-100,100”)转换为long。我目前有一行代码是longxi=long.Parse(x,System.Globalization.NumberStyles.AllowThousands);但是当x是“负数”时,这会中断。我的方法:longxi=long.Parse("-100,253,1",System.Globalization.NumberStyles.AllowLeadingSign&System.Globalization.NumberStyles.AllowThousands);错了,因为它坏了。 最佳答案

c# - DateTime.ParseExact() 比 DateTime.Parse() 快吗

我想知道ParseExact是否比Parse快。我认为它应该是ParseExact,因为您已经提供了格式,但我也认为所有对文化信息的检查都会减慢它的速度。微软是否在任何文件中说明了两者之间的性能差异。要使用的格式是通用的“yyyy/MM/dd”格式。例如:DateTime.Parse(DateText);DateTime.ParseExact(DateText,"yyyy/MM/dd",CultureInfo.InvariantCulture); 最佳答案 您要求两种功能不同(接近但仍然不同)的方法在速度上存在差异。只需选择最合适的

c# - 单声道缺少 System.Numerics.BigInteger.Parse(string,IFormatProvider)

我目前在使用Json.NET/Newtonsoft.JSON时遇到以下错误图书馆:MissingmethodSystem.Numerics.BigInteger::Parse(string,IFormatProvider)inassembly/usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll,referencedinassembly~/dev/Mono/Mercury/Mercury/bin/Debug/Newtonsoft.Json.dll每当从couchDB数据库中检索到的J

c# - 为什么 DateTime.Parse 这么慢?

我对DateTime.Parse的速度之慢感到震惊。此代码运行大约需要100秒;如果我使用正则表达式版本,则需要100毫秒。这是怎么回事?Stopwatchsw=newStopwatch();sw.Start();varre=newRegex(@"(\d\d)/(\d\d)/(\d\d\d\d)(\d\d):(\d\d):(\d\d)",RegexOptions.Compiled);for(inti=0;i编辑:Mark是对的,将CultureInfo.CreateSpecificCulture("en-US")移到循环外很有帮助。我之前没有这样做的原因是我使用VSProfiler分析

c# - "8"的 int.Parse 失败。 int.Parse 总是需要 CultureInfo.InvariantCulture?

我们开发了一个既定的软件,它可以在所有已知的计算机上正常工作,除了一台。问题是解析以“8”开头的字符串。似乎字符串开头的“8”是保留字符。Parsing:int.Parse("8")->Exceptionmessage:Inputstringwasnotinacorrectformat.int.Parse("80")->0int.Parse("88")->8int.Parse("8100")->100CurrentCulture:sv-SECurrentUICulture:en-US使用int.Parse("8",CultureInfo.InvariantCulture)解决了这个问题

c# - LINQ to Entities 无法识别方法 'Int32 Parse(System.String)' 方法,并且无法将此方法翻译成存储表达式

我正在使用EntityFramework,我有一行代码将var转换回数据库的iint。varrecord=context.enrollments.SingleOrDefault(row=>row.userId==int.Parse(UserID)&&row.classId==int.Parse(ClassID));每当我尝试运行它时,我都会收到rhis错误。“LINQtoEntities无法识别‘Int32Parse(System.String)’方法,并且无法将此方法转换为存储表达式。”我也试过varrecord=context.enrollments.FirstOrDefault(